package graph_viewer.structure.clustering;

import java.util.*;
import java.awt.*;
import javax.swing.*;

import graph_viewer.animator.*;
import graph_viewer.canvas.*;
import graph_viewer.structure.*;
import graph_viewer.util.*;

/**
 * define tree cluster
 */
public abstract class Graph_Basic_Cluster_Strategy implements Graph_Cluster_Strategy{	

	public ArrayList build_pre_clustering_animation_metrics( Graph_Canvas graph_canvas, String node_label ){
		return null;
	}

	public ArrayList build_post_clustering_animation_metrics( Graph_Canvas graph_canvas, String node_label ){
		return null;
	}

	
	//==================================================
	// subclasses utils
	//==================================================
	protected ArrayList find_all_demagnified_children( Node cluster ){
		ArrayList all_demagnified_children	= new ArrayList ();

		for ( Iterator _i = cluster.get_children().iterator(); _i.hasNext(); ){
			Node child	= (Node)_i.next();

			if ( child.is_irrelevant() &&  ! child.get_is_psuedo() ){
				all_demagnified_children.add( child ) ;
			}
		}

		return all_demagnified_children;
	}

	//create a psuedo_cluster under a specified cluster
	protected Node create_a_psuedo_child( Node cluster, Graph_Canvas graph_canvas ){

		Node psuedo_cluster	= new Node();				
		
		psuedo_cluster.set_is_psuedo( true );
		psuedo_cluster.set_parent( cluster );
		psuedo_cluster.set_is_closed( true );
		psuedo_cluster.set_DOI(Graph.MIN_DOI );

		psuedo_cluster.set_label( cluster.get_label() + Visual_Component.PSUEDO_LABEL );
		
		ArrayList all_demagnified_children = find_all_demagnified_children( cluster );
		Node a_demg_child	= (Node) all_demagnified_children.get( 0 );

		//Node_Position np = new Node_Position( a_demg_child.get_position().find_center() );

		Node_Position np = new Node_Position( cluster.get_position().find_center() );

		psuedo_cluster.set_position( np ) ;
		
		Node_Position_Helper.set_psuedo_node_size( psuedo_cluster );
	
		

		return psuedo_cluster ;
	}

	


	
} 